Skip to content

fix(globals): use globals for globals #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 15, 2025
Merged

fix(globals): use globals for globals #397

merged 4 commits into from
Aug 15, 2025

Conversation

avivkeller
Copy link
Member

Description

The globals library is updated with every builtin global every month (https://github.com/sindresorhus/globals/blob/main/.github/workflows/update.yml), so we can safely rely on it to populate our builtin globals.

IMO this is a safer alternative than having us manually update this list.

Related Issues

Ref #319

@Copilot Copilot AI review requested due to automatic review settings August 9, 2025 16:15
@avivkeller avivkeller requested a review from a team as a code owner August 9, 2025 16:15
Copy link

vercel bot commented Aug 9, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
api-docs-tooling Ready Ready Preview Aug 15, 2025 8:17pm

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the hardcoded list of JavaScript global objects to use the globals library, which automatically updates with new ES specifications monthly. This change simplifies maintenance by removing the need to manually track and update global objects.

  • Replaces hardcoded arrays of JavaScript globals with dynamic imports from the globals library
  • Moves the globals dependency from devDependencies to dependencies
  • Simplifies the primitive types mapping from an object to an array structure

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

File Description
src/utils/parser/constants.mjs Replaces manual global object lists with globals.builtin and converts primitive mapping to array
src/utils/parser/index.mjs Updates primitive type transformation to work with new array-based mapping
package.json Moves globals from devDependencies to dependencies
.github/dependabot.yml Removes globals from linting dependency group

Copy link

codecov bot commented Aug 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.22%. Comparing base (dc92c22) to head (53c09d8).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #397      +/-   ##
==========================================
- Coverage   74.29%   74.22%   -0.08%     
==========================================
  Files         118      118              
  Lines       11025    10994      -31     
  Branches      695      696       +1     
==========================================
- Hits         8191     8160      -31     
  Misses       2831     2831              
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@avivkeller avivkeller changed the title fix(globals): use \globals\ for globals fix(globals): use globals for globals Aug 9, 2025
@avivkeller
Copy link
Member Author

Blocked by nodejs/node#59421

@avivkeller
Copy link
Member Author

Unrelated, but https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Data_structures#Data_types isn't a valid URL, which is also defined in this file

Copy link
Member

@ovflowd ovflowd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going down this approach, wouldn't it be easier to use Object.keys(self)?

@ovflowd
Copy link
Member

ovflowd commented Aug 10, 2025

cc @aduh95 / @nodejs/collaborators

@avivkeller
Copy link
Member Author

If we're going down this approach, wouldn't it be easier to use Object.keys(self)?

No, firstly, see #397 (comment). Secondly, we aren't building the docs on for same version of Node.js as we are on, so the list would be incomplete

@cclauss

This comment has been minimized.

@ovflowd

This comment has been minimized.

@cclauss

This comment has been minimized.

@avivkeller

This comment has been minimized.

@avivkeller

This comment has been minimized.

@ovflowd

This comment was marked as off-topic.

@avivkeller
Copy link
Member Author

Need to fix one thing, then this'll be good to go

@ovflowd
Copy link
Member

ovflowd commented Aug 15, 2025

@avivkeller conflicts?

@avivkeller avivkeller force-pushed the use-globals-library branch from 01f46a8 to 53c09d8 Compare August 15, 2025 20:15
@ovflowd ovflowd merged commit 0ecb11e into main Aug 15, 2025
18 checks passed
@ovflowd ovflowd deleted the use-globals-library branch August 15, 2025 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants